package com.recommend.service.admin.impl;

import java.util.List;

import javax.annotation.Resource;

import com.recommend.domain.MovieDomain;
import com.recommend.persistence.MovieDomainMapper;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.recommend.dto.admin.RecommendDto;
import com.recommend.persistence.RecommendDomainMapper;
import com.recommend.service.RecommendService;

/**
 * Created by lw.
 */
@Service
@Transactional
public class RecommendServiceImpl implements RecommendService{
    private final static Logger logger = org.slf4j.LoggerFactory.getLogger(RecommendServiceImpl.class);

    @Resource
    private RecommendDomainMapper recommendDomainMapper;
    @Resource
    private MovieDomainMapper movieDomainMapper;

    @Override
    public List<RecommendDto> getAllRecommend(){
        List<RecommendDto> recommendDtos = recommendDomainMapper.selectAll();
        logger.info("===========select all recommend:{}", recommendDtos.size());
        for(RecommendDto recommendDto : recommendDtos){
            logger.info("---------customer:{}, movie:{}, time:{}--- ", recommendDto.getCustomerName(), recommendDto.getMovieTitle(), recommendDto.getTimestamp());
        }
        return recommendDtos;
    }

    @Override
    public List<RecommendDto> getRecommendSelective(RecommendDto recommendDto){
        List<RecommendDto> recommendDtos = recommendDomainMapper.selectListSelective(recommendDto);
        logger.info("===========select recommend selective:count{}", recommendDtos.size());
        return recommendDtos;
    }

    @Override
    public List<MovieDomain> getRecommendByCustomerId(int customerId){
        List<MovieDomain> movieDomains = movieDomainMapper.selectRecommendMovieByCustomerId(customerId);
        logger.info("===========select recommend selective:count{}", movieDomains.size());
        return movieDomains;
    }
}
